home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / BORLAND TURBO / 32SNIPIT.PAK / BATMOVE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  20.8 KB  |  551 lines

  1. // BDE32 3.x - (C) Copyright 1996 by Borland International
  2.  
  3. // batmove.c
  4. #include "snipit.h"
  5.  
  6. #define NAMELEN  10 // Length of the name fields
  7. #define PLACELEN 20 // Length of the POB field
  8. #define DATELEN  11 // Display length for a date field: mm\dd\yyyy
  9.  
  10. static const char szDBTblName[] = "DBPeople";
  11. static const char szDBTblType[] = szDBASE;
  12.  
  13. // Field descriptor used in creating a table.
  14. static SNIPFAR FLDDesc DBfldDesc[] = {
  15.                           { // Field 1 - First Name
  16.                             1,            // Field number
  17.                             "Name",       // Field name
  18.                             fldZSTRING,   // Field type
  19.                             fldUNKNOWN,   // Field subtype
  20.                             NAMELEN,      // Field size ( 1 or 0, except
  21.                                           //     BLOb or CHAR field )
  22.                             0,            // Decimal places ( 0 )
  23.                                           //     computed
  24.                             0,            // Offset in record ( 0 )
  25.                             0,            // Length in bytes  ( 0 )
  26.                             0,            // For Null bits    ( 0 )
  27.                             fldvNOCHECKS, // Validity checks   ( 0 )
  28.                             fldrREADWRITE // Rights
  29.                           },
  30.                           { // Field 2 - Place of Birth
  31.                             2, "POB", fldZSTRING, fldUNKNOWN, PLACELEN,
  32.                             0, 0, 0, 0, fldvNOCHECKS, fldrREADWRITE
  33.                           },
  34.                           { // Field 3 - Date of Birth
  35.                             3, "DOB", fldZSTRING, fldUNKNOWN, DATELEN,
  36.                             0, 0, 0, 0, fldvNOCHECKS, fldrREADWRITE
  37.                           }                  
  38.                      };  // Array of field descriptors
  39.  
  40. // Index descriptor - describes the index associated with the
  41. // table. 
  42. static SNIPFAR IDXDesc DBidxDesc[] = {
  43.                     {  // Primary Index - Full Name
  44.                        "Name",      // Name
  45.                        1,           // Number
  46.                        {"NAME"},    // Tag name ( for dBase )
  47.                        { NULL },    // Optional format ( BTREE,
  48.                                     //   HASH, etc )
  49.                        FALSE,       // Primary?
  50.                        FALSE,       // Unique?
  51.                        FALSE,       // Descending?
  52.                        TRUE,        // Maintained?
  53.                        FALSE,       // SubSet?
  54.                        FALSE,       // Expression index?
  55.                        NULL,        // for QBE only
  56.                        1,           // Fields in key
  57.                        1,           // Length in bytes
  58.                        FALSE,       // Index out of date?
  59.                        0,           // Key type of expression
  60.                        { 1 },       // Array of field numbers
  61.                        { 0 },       // Key expression
  62.                        { 0 },       // Key condition
  63.                        FALSE,       // Case insensitive
  64.                        0,           // Block size in bytes
  65.                        0            // Restructure number
  66.                     },
  67.                     {  // Secondary index 1 - Single field
  68.                        "POB", 2, {"POB1"}, { NULL }, FALSE, FALSE, FALSE,
  69.                        TRUE, FALSE, FALSE, NULL, 1, 1, FALSE, 0, { 2 },
  70.                        { 0 }, { 0 }, FALSE, 0, 0
  71.                     },
  72.                     {  // Secondary index 2 - Single field
  73.                        "DOB", 3, {"DOB1"}, { NULL }, FALSE, FALSE, FALSE,
  74.                        TRUE, FALSE, FALSE, NULL, 1, 1, FALSE, 0, { 3 },
  75.                        { 0 }, { 0 }, FALSE, 0, 0
  76.                     }
  77.  
  78.                 };
  79.  
  80. static const char szPXTblName[] = "PXPeople";
  81. static const char szPXTblType[] = szPARADOX; 
  82.  
  83. // Field descriptor used in creating a table.
  84. static SNIPFAR FLDDesc PXfldDesc[] = {
  85.               { // Field 1 - First Name
  86.                   1,            // Field number
  87.                   "First Name", // Field name
  88.                   fldZSTRING,   // Field type
  89.                   fldUNKNOWN,   // Field subtype
  90.                   NAMELEN,      // Field size ( 1 or 0, except
  91.                                 //     BLOB or CHAR field )
  92.                   0,            // Decimal places ( 0 )
  93.                                 //     computed
  94.                   0,            // Offset in record ( 0 )
  95.                   0,            // Length in bytes  ( 0 )
  96.                   0,            // For Null bits    ( 0 )
  97.                   fldvNOCHECKS, // Validity checks   ( 0 )
  98.                   fldrREADWRITE // Rights
  99.               },
  100.               { // Field 2 - Middle Name
  101.                   2, "Middle Name", fldZSTRING, fldUNKNOWN,
  102.                   NAMELEN, 0, 0, 0, 0,
  103.                   fldvNOCHECKS, fldrREADWRITE
  104.               },
  105.               { // Field 3 - Last Name
  106.                   3, "Last Name", fldZSTRING, fldUNKNOWN,
  107.                   NAMELEN, 0, 0, 0, 0,
  108.                   fldvNOCHECKS, fldrREADWRITE
  109.               },
  110.               { // Field 4 - Date of Birth
  111.                   4, "DOB", fldDATE, fldUNKNOWN,
  112.                   0, 0, 0, 0, 0,
  113.                   fldvNOCHECKS, fldrREADWRITE
  114.               },
  115.               { // Field 5 - Place of Birth
  116.                   5, "POB", fldZSTRING, fldUNKNOWN,
  117.                   PLACELEN, 0, 0, 0, 0,
  118.                   fldvNOCHECKS, fldrREADWRITE
  119.               }
  120.              };  // Array of field descriptors
  121.  
  122. // Index descriptor - describes the index associated with the
  123. // table. 
  124. static SNIPFAR IDXDesc PXidxDesc[] = {
  125.             { // Primary Index - Full Name
  126.                 "Full Name",  // Name
  127.                 1,            // Number
  128.                 { NULL },     // Tag name ( for dBase )
  129.                 { NULL },     // Optional format ( BTREE,
  130.                               // HASH, etc )
  131.                 TRUE,         // Primary?
  132.                 TRUE,         // Unique?
  133.                 FALSE,        // Descending?
  134.                 TRUE,         // Maintained?
  135.                 FALSE,        // SubSet?
  136.                 FALSE,        // Expression index?
  137.                 NULL,         // for QBE only
  138.                 3,            // Fields in key
  139.                 1,            // Length in bytes
  140.                 FALSE,        // Index out of date?
  141.                 0,            // Key type of expression
  142.                 { 1,2,3 },    // Array of field numbers
  143.                 { 0 },        // Key expression
  144.                 { 0 },        // Key condition
  145.                 FALSE,        // Case insensitive
  146.                 0,            // Block size in bytes
  147.                 0             // Restructure number
  148.             },
  149.             { // Secondary Index 1 - Single field - Maintained,
  150.               //     Case insensitive
  151.                 "Last Name", 2, { NULL }, { NULL }, FALSE,  FALSE,  FALSE,
  152.                 TRUE, FALSE, FALSE, NULL, 1, 1, FALSE, 0, { 3 }, { 0 },
  153.                 { 0 }, TRUE, 0, 0
  154.             },
  155.             { // Secondary Index 2 - Single field - Not maintained
  156.                 "POB", 3, { NULL }, { NULL }, FALSE, FALSE, FALSE, FALSE,
  157.                 FALSE, FALSE, NULL, 1, 1, FALSE, 0, { 5 }, { 0 }, { 0 },
  158.                 FALSE, 0, 0
  159.             }
  160.         };
  161.  
  162. static DBIResult AddRecord(phDBICur, pCHAR, pCHAR, pCHAR, UINT16, UINT16, UINT16,
  163.                     pCHAR);
  164. static DBIResult AddRecordDB(phDBICur hCur, pCHAR pszFirst, pCHAR pszPOB,
  165.                              pCHAR pszDate);
  166.  
  167. static DBIResult CreateDBTable(phDBIDb);
  168. static DBIResult CreatePXTable(phDBIDb);
  169.  
  170. //=====================================================================
  171. //  Function:
  172. //          BatchMove();
  173. //
  174. //  Description:
  175. //          This example shows how to use the DbiBatchMove function to
  176. //          copy data from a Paradox table to a dBASE table.
  177. //=====================================================================
  178. void
  179. BatchMove (void)
  180. {
  181.     hDBIDb      hDb;                // Handle to the database
  182.     hDBICur     hCurDB;             // dBASE cursor handle
  183.     hDBICur     hCurPX;             // PARADOX cursor handle
  184.     UINT32      ulNumRecs = 0;      // Number of records moved in BatchMove
  185.     UINT32      ulChangedRecs = 0;  // Number of records changed in BatchMove
  186.     UINT32      ulKeyViolRecs = 0;  // Number of key violations in BatchMove
  187.     UINT32      ulProbRecs = 0;     // Number of problem recs in BatchMove
  188.     UINT16      uaSrcRecs[3] = {1,5,4}; // Fields to use in the source table
  189.     DBIResult   rslt;               // Return value from IDAPI functions    
  190.     DBIPATH     szKeyViol   = "KEYVIOL";
  191.     DBIPATH     szProblems  = "PROBLEMS";
  192.     DBIPATH     szChanged   = "CHANGED";    // Names of temporary tables.
  193.  
  194.     Screen("*** Table Copy Example ***\r\n");
  195.  
  196.     BREAK_IN_DEBUGGER();
  197.  
  198.     Screen("    Initializing IDAPI...");
  199.     if (InitAndConnect(&hDb) != DBIERR_NONE)
  200.     {                                       
  201.         Screen("\r\n*** End of Example ***");
  202.         return;
  203.     }
  204.  
  205.     Screen("    Setting the database directory...");
  206.     rslt = DbiSetDirectory(hDb, (pCHAR) szTblDirectory);
  207.     ChkRslt(rslt, "SetDirectory");
  208.  
  209.     Screen("    Create the %s dBASE table...", szDBTblName);
  210.     if (CreateDBTable(&hDb) != DBIERR_NONE)
  211.     {
  212.         CloseDbAndExit(&hDb);
  213.         Screen("\r\n*** End of Example ***");
  214.         return;
  215.     }
  216.  
  217.     Screen("    Open the %s table which we just created...", szDBTblName);
  218.     rslt = DbiOpenTable(hDb, (pCHAR) szDBTblName, (pCHAR) szDBTblType,
  219.                         NULL, NULL, 0, dbiREADWRITE, dbiOPENSHARED,
  220.                         xltFIELD, FALSE, NULL, &hCurDB);
  221.     if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
  222.     {
  223.         CloseDbAndExit(&hDb);
  224.         Screen("\r\n*** End of Example ***");
  225.         return;
  226.     }
  227.  
  228.     rslt = DbiSetToBegin(hCurDB);
  229.     ChkRslt(rslt, "SetToBegin");
  230.  
  231.     Screen("    Displaying the %s table...", szDBTblName);
  232.     DisplayTable(hCurDB, 0);
  233.  
  234.     Screen("\r\n    Create the %s PARADOX table...", szPXTblName);
  235.     if (CreatePXTable(&hDb) != DBIERR_NONE)
  236.     {
  237.         CloseDbAndExit(&hDb);
  238.         Screen("\r\n*** End of Example ***");
  239.         return;
  240.     }
  241.  
  242.     Screen("    Open the %s table which we just created...",
  243.            szPXTblName);
  244.     rslt = DbiOpenTable(hDb, (pCHAR) szPXTblName, (pCHAR) szPXTblType,
  245.                         NULL, NULL, 0, dbiREADWRITE, dbiOPENSHARED,
  246.                         xltFIELD, FALSE, NULL, &hCurPX);
  247.     if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
  248.     {
  249.         CloseDbAndExit(&hDb);
  250.         Screen("\r\n*** End of Example ***");
  251.         return;
  252.     }
  253.  
  254.     rslt = DbiSetToBegin(hCurPX);
  255.     ChkRslt(rslt, "SetToBegin");
  256.  
  257.     Screen("    Displaying the %s table...", szPXTblName);
  258.     DisplayTable(hCurPX, 0);
  259.  
  260.     rslt = DbiSetToBegin(hCurPX);
  261.     ChkRslt(rslt, "SetToBegin");
  262.  
  263.     Screen("\r\n    Appending the %s table to the %s table...",
  264.            szPXTblName, szDBTblName);
  265.     rslt = DbiBatchMove(NULL, hCurPX, NULL, hCurDB, batAPPEND, 3,
  266.                         uaSrcRecs, 0, 0, 0, szKeyViol, szProblems,
  267.                         szChanged, &ulProbRecs, &ulKeyViolRecs,
  268.                         &ulChangedRecs, FALSE, FALSE, &ulNumRecs, TRUE);
  269.     ChkRslt(rslt, "Batch Move");
  270.  
  271.     rslt = DbiSetToBegin(hCurDB);
  272.     ChkRslt(rslt, "SetToBegin");
  273.  
  274.     Screen("    Displaying the updated %s table...", szDBTblName);
  275.     DisplayTable(hCurDB, 0);
  276.  
  277.     Screen("\r\n    Close the %s table...", szPXTblName);
  278.     rslt = DbiCloseCursor(&hCurPX);
  279.     ChkRslt(rslt, "CloseCur");
  280.  
  281.     Screen("    Delete the %s table...", szPXTblName);
  282.     rslt = DbiDeleteTable(hDb,(pCHAR) szPXTblName, (pCHAR) szPXTblType);
  283.     ChkRslt(rslt, "DeleteTable");
  284.  
  285.     Screen("    Close the %s table...", szDBTblName);
  286.     rslt = DbiCloseCursor(&hCurDB);
  287.     ChkRslt(rslt, "CloseCur");
  288.  
  289.     Screen("    Delete the %s table...", szDBTblName);
  290.     rslt = DbiDeleteTable(hDb,(pCHAR) szDBTblName, (pCHAR) szDBTblType);
  291.     ChkRslt(rslt, "DeleteTable");
  292.  
  293.     Screen("    Close the database and exit IDAPI...");
  294.     CloseDbAndExit(&hDb);
  295.  
  296.     Screen("\r\n*** End of Example ***");
  297. }
  298.  
  299. //=====================================================================
  300. //  Function:
  301. //          CreateDBTable(phDb));
  302. //
  303. //  Input:  phDb    - Pointer to the database handle.
  304. //
  305. //  Return: Result of the table initialization.
  306. //
  307. //  Description:
  308. //          This function creates a dBASE table and fills the table
  309. //          with a few records.  
  310. //=====================================================================
  311. DBIResult
  312. CreateDBTable (phDBIDb phDb)
  313. {
  314.     DBIResult   rslt;               // Value returned from IDAPI functions
  315.     hDBICur     hCur;               // Cursor handle for the table that is
  316.                                     //   created.
  317.     CRTblDesc   crTblDsc;           // Table descriptor
  318.     BOOL        bOverWrite = TRUE;  // Overwrite, yes/no flag
  319.  
  320.     // The number of fields in the table - note that DBfldDesc is defined
  321.     // globally.
  322.     const unsigned uNumFields = sizeof(DBfldDesc) / sizeof (DBfldDesc[0]);
  323.  
  324.     // Number of indexes to be created when the table is created - note
  325.     // that idxDesc is defined globally.
  326.     const unsigned uNumIndexes = sizeof(DBidxDesc) / sizeof(DBidxDesc[0]);
  327.  
  328.     // Initialize the table create descriptor.
  329.     memset(&crTblDsc, 0, sizeof(CRTblDesc));
  330.     strcpy(crTblDsc.szTblName, szDBTblName);
  331.     strcpy(crTblDsc.szTblType, szDBTblType);
  332.     crTblDsc.iFldCount     = (UINT16)uNumFields;
  333.     crTblDsc.pfldDesc      = DBfldDesc;
  334.     crTblDsc.iIdxCount     = (UINT16)uNumIndexes ;
  335.     crTblDsc.pidxDesc      = DBidxDesc ;
  336.  
  337.     // Create the table using information supplied in the table
  338.     // descriptor above.
  339.     rslt = DbiCreateTable(*phDb, bOverWrite, &crTblDsc);
  340.     if (ChkRslt(rslt, "CreateTable") != DBIERR_NONE)
  341.     {
  342.         return rslt;
  343.     }
  344.  
  345.     // Open the table.
  346.     rslt = DbiOpenTable(*phDb, (pCHAR) szDBTblName, (pCHAR) szDBTblType,
  347.                         NULL, NULL, 0, dbiREADWRITE, dbiOPENSHARED,
  348.                         xltFIELD, FALSE, NULL, &hCur);
  349.     if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
  350.     {
  351.         return rslt;
  352.     }
  353.  
  354.     // Add records to the table.
  355.     AddRecordDB(&hCur, "Jeffery", "San Jose", "1/28/1967");
  356.     AddRecordDB(&hCur, "William", "New York", "8/12/1970");
  357.     AddRecordDB(&hCur, "Jimmy", "San Francisco", "3/10/1924");
  358.     AddRecordDB(&hCur, "Larry", "Germany", "12/22/1933");
  359.  
  360.     rslt = DbiCloseCursor(&hCur);
  361.     ChkRslt(rslt, "CloseCursor");
  362.  
  363.     return rslt;
  364. }
  365.  
  366. //=====================================================================
  367. //  Function:
  368. //          CreatePXTable(phDb);
  369. //
  370. //  Input:  phDb    - Pointer to the database handle.
  371. //
  372. //  Return: Result of the table initialization.
  373. //
  374. //  Description:
  375. //          This function will create a Paradox table and fill the
  376. //          table with a few records.  
  377. //=====================================================================
  378. DBIResult
  379. CreatePXTable (phDBIDb phDb)
  380. {
  381.     DBIResult   rslt;              // Value returned from IDAPI functions.
  382.     hDBICur     hCur;              // Cursor handle for the table that is
  383.                                    //   created.
  384.     CRTblDesc   crTblDsc;          // Table descriptor.
  385.     BOOL        bOverWrite = TRUE; // Overwrite, yes/no flag.
  386.  
  387.     // The number of fields in the table - note that PXfldDesc is defined
  388.     // globally.
  389.     const unsigned uNumFields = sizeof(PXfldDesc) / sizeof (PXfldDesc[0]);
  390.  
  391.     // Number of indexes to be created when the table is created - note
  392.     // that idxDesc is defined globally.
  393.     const unsigned uNumIndexes = sizeof(PXidxDesc) / sizeof(PXidxDesc[0]);
  394.  
  395.     // Initialize the table create descriptor.
  396.     memset(&crTblDsc, 0, sizeof(CRTblDesc));
  397.     strcpy(crTblDsc.szTblName, szPXTblName);
  398.     strcpy(crTblDsc.szTblType, szPXTblType);
  399.     crTblDsc.iFldCount     = (UINT16)uNumFields;
  400.     crTblDsc.pfldDesc      = PXfldDesc;
  401.     crTblDsc.iIdxCount     = (UINT16)uNumIndexes;
  402.     crTblDsc.pidxDesc      = PXidxDesc;
  403.  
  404.     // Create the table using information supplied in the table
  405.     // descriptor above.
  406.     rslt = DbiCreateTable(*phDb, bOverWrite, &crTblDsc);
  407.     if (ChkRslt(rslt, "CreateTable") != DBIERR_NONE)
  408.     {
  409.         return rslt;
  410.     }
  411.  
  412.     rslt = DbiOpenTable(*phDb, (pCHAR) szPXTblName, (pCHAR) szPXTblType,
  413.                         NULL, NULL, 0, dbiREADWRITE, dbiOPENSHARED,
  414.                         xltFIELD, FALSE, NULL, &hCur);
  415.     if (ChkRslt(rslt, "OpenTable") != DBIERR_NONE)
  416.     {
  417.         return rslt;
  418.     }
  419.  
  420.     AddRecord(&hCur, "David", "John", "Smith", 7, 28, 1968, "Chicago");
  421.     AddRecord(&hCur, "Tracy", "Joy", "Thomas", 12, 27, 1969, "Hermosa Beach");
  422.     AddRecord(&hCur, "John", "Boy", "Doe", 2, 7, 1954, "Ohmaha");
  423.     AddRecord(&hCur, "Klaus", "Epstein", "Stern", 4, 13, 1970, "Tel Aviv");
  424.  
  425.     rslt = DbiCloseCursor(&hCur);
  426.     ChkRslt(rslt, "CloseCursor");
  427.  
  428.     return rslt;
  429. }
  430.  
  431. //=====================================================================
  432. //  Function:
  433. //          AddRecordDB(hCur, pszName, pszPOB, pszDate);
  434. //
  435. //  Input:  hCur    - Cursor handle.
  436. //          pszName - Value for the name field.
  437. //          pszDate - Value for the date field.
  438. //          pszPOB  - Value for the "Place of Birth" field.
  439. //
  440. //  Return: Result of adding the record to the table
  441. //
  442. //  Description:
  443. //          This function will add a record to the given dBASE table.
  444. //=====================================================================
  445. DBIResult
  446. AddRecordDB (phDBICur hCur, pCHAR pszName, pCHAR pszPOB, pCHAR pszDate)
  447. {
  448.     DBIResult   rslt;       // Value returned from IDAPI functions
  449.     CURProps    TblProps;   // Table properties
  450.     pBYTE       pRecBuf;    // Record buffer
  451.  
  452.     //  Allocate a record buffer
  453.     rslt = DbiGetCursorProps(*hCur, &TblProps);
  454.     ChkRslt(rslt, "GetProps");
  455.  
  456.     pRecBuf = (pBYTE) malloc(TblProps.iRecBufSize * sizeof(BYTE));
  457.     if (pRecBuf == NULL)
  458.     {
  459.         Screen("    Error - Out of memory");
  460.         return DBIERR_NOMEMORY;
  461.     }
  462.  
  463.     //  Clear, fill, and insert the record.
  464.     rslt = DbiInitRecord(*hCur, pRecBuf);
  465.     ChkRslt(rslt, "InitRecord");
  466.  
  467.     rslt = DbiPutField(*hCur, 1, pRecBuf, (pBYTE) pszName);
  468.     ChkRslt(rslt, "PutField");
  469.  
  470.     rslt = DbiPutField(*hCur, 2,  pRecBuf, (pBYTE) pszPOB);
  471.     ChkRslt(rslt, "PutField");
  472.  
  473.     rslt = DbiPutField(*hCur, 3,  pRecBuf, (pBYTE) pszDate);
  474.     ChkRslt(rslt, "PutField");
  475.  
  476.     rslt = DbiInsertRecord(*hCur, dbiNOLOCK, pRecBuf);
  477.     ChkRslt(rslt, "InsertRec");
  478.  
  479.     free(pRecBuf);
  480.  
  481.     return rslt;
  482. }
  483.  
  484. //=====================================================================
  485. //  Function:
  486. //          AddRecord();
  487. //
  488. //  Input:  pointer to the cursor handle, first name (pCHAR), middle
  489. //          name (pCHAR), last name (pCHAR), Month of Birth (UINT16), Day
  490. //          of Birth (UINT16), Year of Birth (UINT16), Place of birth
  491. //          (pCHAR).
  492. //
  493. //  Return: Result of adding the record to the table
  494. //
  495. //  Description:
  496. //          This function will add a record to the given table.
  497. //=====================================================================
  498. DBIResult
  499. AddRecord (phDBICur hCur, pCHAR pszFirst, pCHAR pszMiddle, pCHAR pszLast,
  500.            UINT16 uMonth, UINT16 uDay, UINT16 uYear, pCHAR pszPOB)
  501. {
  502.     DBIDATE     Date;           // Date structure
  503.     DBIResult   rslt;           // Value returned from IDAPI functions
  504.     CURProps    TblProps;       // Table Properties
  505.     pBYTE       pRecBuf;        // Record Buffer
  506.  
  507.     //  Allocate a record buffer
  508.     rslt = DbiGetCursorProps(*hCur, &TblProps);
  509.     ChkRslt(rslt, "GetCursorProps");
  510.  
  511.     pRecBuf = (pBYTE) malloc(TblProps.iRecBufSize * sizeof(BYTE));
  512.     if (pRecBuf == NULL)
  513.     {
  514.         return DBIERR_NOMEMORY;
  515.     }
  516.  
  517.     //  Make sure we're starting with a clean record buffer
  518.     rslt = DbiInitRecord(*hCur, pRecBuf);
  519.     ChkRslt(rslt, "InitRecord");
  520.  
  521.     // First Name
  522.     rslt = DbiPutField(*hCur, 1, pRecBuf, (pBYTE) pszFirst);
  523.     ChkRslt(rslt, "PutField");
  524.  
  525.     // Middle Name
  526.     rslt = DbiPutField(*hCur, 2, pRecBuf, (pBYTE) pszMiddle);
  527.     ChkRslt(rslt, "PutField");
  528.  
  529.     // Last Name
  530.     rslt = DbiPutField(*hCur, 3, pRecBuf, (pBYTE) pszLast);
  531.     ChkRslt(rslt, "PutField");
  532.  
  533.     // DOB
  534.     rslt = DbiDateEncode(uMonth, uDay, uYear, &Date);
  535.     ChkRslt(rslt, "DateEncode");
  536.  
  537.     rslt = DbiPutField(*hCur, 4,  pRecBuf, (pBYTE) &Date);
  538.     ChkRslt(rslt, "PutField");
  539.  
  540.     // Place of Birth
  541.     rslt = DbiPutField(*hCur, 5,  pRecBuf, (pBYTE) pszPOB);
  542.     ChkRslt(rslt, "PutField");
  543.  
  544.     rslt = DbiInsertRecord(*hCur, dbiNOLOCK, pRecBuf),
  545.     ChkRslt(rslt, "InsertRecord");
  546.  
  547.     free(pRecBuf);
  548.  
  549.     return rslt;
  550. }
  551.